package com.vrp3d.web;

import com.vrp3d.common.response.RestResponse;
import com.vrp3d.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 文件相关服务
 *
 * @author vrp3d
 */
@Api("文件")
@Slf4j
@Validated
@RestController
@RequestMapping("/file")
public class FileController extends AbsController {

    @Autowired
    private FileService fileService;

    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "上传文件_保留文件本身名称")
    @RequestMapping(value = "/uploadKeepTheFileName", method = RequestMethod.POST)
    public RestResponse uploadKeepTheFileName(@ApiParam(value = "待上传文件", required = true) @RequestParam(value = "file") MultipartFile file) {
        String result = fileService.uploadKeepTheFileName(file);
        return new RestResponse().put(result);
    }

}
